axios.defaults.baseURL = 'https://codelover.club';

function Conversiontime(isoDateString) {
    // 创建一个新的Date对象来解析ISO日期字符串
    let date = new Date(isoDateString);

    // 获取年、月、日、时、分、秒
    let year = date.getFullYear();
    let month = ('0' + (date.getMonth() + 1)).slice(-2); // getMonth返回的月份是从0开始的，所以需要+1
    let day = ('0' + date.getDate()).slice(-2);
    let hours = ('0' + date.getHours()).slice(-2);
    let minutes = ('0' + date.getMinutes()).slice(-2);
    let seconds = ('0' + date.getSeconds()).slice(-2);

    // 格式化输出
    return year + '年' + month + '月' + day + '日 ' + hours + ':' + minutes + ':' + seconds;
}

//防抖
function debounce(fn, t = 100) {
    let timer
    return function () {
        console.log(t)
        if (timer) clearTimeout(timer)
        timer = setTimeout(() => {
            fn()
        }, t);
    }
}

//导出excel
function toExcel(name){
    //window.location.href='<%=basePath%>pmb/excelShowInfo.do';
    //获取表格
    var exportFileContent = document.getElementById("table_report").outerHTML;
    //设置格式为Excel，表格内容通过btoa转化为base64，此方法只在文件较小时使用(小于1M)
    //exportFileContent=window.btoa(unescape(encodeURIComponent(exportFileContent)));
    //var link = "data:"+MIMEType+";base64," + exportFileContent;
    //使用Blob
    var blob = new Blob([exportFileContent], {type: "text/plain;charset=utf-8"});     	//解决中文乱码问题
    blob =  new Blob([String.fromCharCode(0xFEFF), blob], {type: blob.type});
    //设置链接
    var link = window.URL.createObjectURL(blob);
    var a = document.createElement("a");    //创建a标签
    a.download = `${name}.xls`;  //设置被下载的超链接目标（文件名）
    a.href = link;                            //设置a标签的链接
    document.body.appendChild(a);            //a标签添加到页面
    a.click();                                //设置a标签触发单击事件
    document.body.removeChild(a);            //移除a标签
}


